//
//  BannerView.swift
//  AIMobileOfficeiOSApp
//
//  Created by 邓杰 on 2018/6/22.
//  Copyright © 2018年 AIMobileOffice. All rights reserved.
//

import Foundation
import UIKit

private let cellID="cell"

class BannerView:UIView,UICollectionViewDelegate,UICollectionViewDataSource
{
   fileprivate var collectionView: UICollectionView!
    var images:[PPT_image]=[
        PPT_image(imageName: "cafedeadend.jpg"),
        PPT_image(imageName: "homei.jpg"),
        PPT_image(imageName: "teakha.jpg"),
        PPT_image(imageName: "cafeloisl.jpg"),
        PPT_image(imageName: "petiteoyster.jpg"),
        PPT_image(imageName: "forkeerestaurant.jpg"),
        PPT_image(imageName: "posatelier.jpg"),
        PPT_image(imageName: "bourkestreetbakery.jpg"),
        PPT_image(imageName: "haighschocolate.jpg"),
        PPT_image(imageName: "palominoespresso.jpg"),
        PPT_image(imageName: "upstate.jpg"),
        PPT_image(imageName: "traif.jpg"),
        PPT_image(imageName: "grahamavenuemeats.jpg"),
        PPT_image(imageName: "wafflewolf.jpg"),
        PPT_image(imageName: "fiveleaves.jpg"),
        PPT_image(imageName: "cafelore.jpg"),
        PPT_image(imageName: "confessional.jpg"),
        PPT_image(imageName: "barrafina.jpg"),
        PPT_image(imageName: "donostia.jpg"),
        PPT_image(imageName: "royaloak.jpg"),
        PPT_image(imageName: "caskpubkitchen.jpg")
    ]
    
    /*
    func setupCollectionView() {
        self.collectionView.register(pptImageCellController.self, forCellWithReuseIdentifier: cellID)
    }
    */
 
 
   // self.collectionView.register(pptImageCellController.self, forCellWithReuseIdentifier: cellID)
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
         return images.count
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellID, for: indexPath) as! pptImageCellController
        
        // Configure the cell
        print(images[indexPath.row].name)
        if(cell.showImage==nil)
        {
            print("optional value fail")
        }
        else
        {
            cell.ImageShow.image=UIImage(named: images[indexPath.row].imagename)
        }
        
        return cell
    }        
}
